function rules(obj) {
    return {

        name: [
            {
                validator: (rule, value, callback) => {
                    let reg = /^[a-zA-Z]\w{3,15}$/g;
                    if (value == "") {
                        callback(new Error("请输入姓名"));
                    } else {
                        if (reg.test(value)) {
                            callback();
                        } else {
                            callback(new Error("请输入以字母开头至少4-15个字符"));
                        }
                    }
                },
                triggle: "blur",
                required: true
            }
        ],
        pass: [
            {
                validator: (rule, value, callback) => {
                    // //如果是编辑就禁用规则
                    if (obj.manages.id) {
                        callback();
                        return;
                    }
                    let reg = /^(?=.*\d)(?=.*[a-z]).{8,20}$/g;
                    let flag = reg.test(value);
                    if ((value = "")) {
                        callback(new Error("请输入密码"));
                    } else {
                        if (flag) {
                            callback();
                        } else {
                            callback(
                                new Error("密码必须包含小写字母和数字，长度在8-20之间")
                            );
                        }
                    }
                },
                triggle: "blur",
                required: true
            }
        ],
        checkPass: [
            {
                validator: (rule, value, callback) => {
                    // //如果是编辑就禁用规则
                    if (obj.manages.id) {
                        console.log(111)
                        callback();
                        return;
                    }
                    let flag = value == obj.manages.pass;
                    if (value == "") {
                        callback(new Error("请再输入一次密码"));
                    } else {
                        if (flag) {
                            callback();
                        } else {
                            callback(new Error("两次输入的密码不一致"));
                        }
                    }
                },
                triggle: "blur",
                required: true
            }
        ],
        time: [
            {
                required: true,
                message: "请选择日期",
                trigger: "change"
            }
        ]

    }
}
export default rules